Skip to content

csharp: new T() on a staged library type is not an external constructor (#1339) - #2025

Merged
swapnilpaliwal-sd merged 3 commits into
0.2.4from
fix/csharp-staged-ctor-not-external
Nov 19, 2026
Merged

swapnilpaliwal-sd merged 3 commits into
0.2.4from
fix/csharp-staged-ctor-not-external

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

Fixes #1339

Summary

With a C# library staged through --library, new Store() on a library type was still reported as a construction of an unstaged dependency. Both shapes from the issue still reproduced on 0.2.4:

Store in the staged library before after
declares public Store() { } 2 rows: the library constructor, and external:Store.<constructor> (provenance external) 1 row: the library constructor
declares no constructor 1 row: external:Store.<constructor> (provenance external) 1 row: generated:Acme.Store#<constructor>/0, provenance lib, tier boundary_lib
  1. The second row on a declared constructor. The cause is not type_name_unresolved as the issue guessed: the external clause keyed on it needs !expr_new_type, and the type does resolve. It is the "staged type whose constructor is not carried" clause in external-types.dl, which is gated on !call_ctor_target_accepts(prov, e, ac). That relation re-checked ctor_accepts_argc under the site's provenance (client), while a staged constructor is declared under lib, so it never held for a client new reaching a library constructor, and a resolved site was also labelled unstaged. call_ctor_target already admits a constructor only where it accepts the argument count, under the provenance the constructor is declared in, so call_ctor_target_accepts now reads it as is.
  2. external on a staged type with no carried constructor. new T() compiles only if T has a parameterless constructor, declared or compiler-supplied, so the target exists and belongs to a type the run was given. A new relation, staged_parameterless_ctor, names it generated:<qualified type name>#<constructor>/0. The bundle already gives a generated: id a methods row (provenance generated, owner the type), as it does for a delegate member's Invoke. The edge is callee_provenance = lib, tier boundary_lib. The site still stays out of known_implicit_ctor: a library IR is a signature subset, so it cannot show the type declares no constructor (call_ctor_implicit is unchanged).
    A new whose argument count no carried constructor accepts, where the IR does carry some constructor, keeps its external: label, the same as an uncarried method on a staged type.

Review these first

  • graph/csharp/engine/resolution/external-types.dl: call_ctor_target_accepts, the new staged_parameterless_ctor, and the !staged_parameterless_ctor guard on the staged-type constructor clause.
  • graph/csharp/engine/call-edge-generation/call_chain.dl: the staged_parameterless_ctor edge, plus its site_leaves_client and call_has_edge clauses. Without call_has_edge, the site also kept a - - boundary_lib row.
  • graph/bundle/schema.ts (and the regenerated SCHEMA.md): methods.provenance = generated and call_edges.callee_provenance = lib for C# now mention the constructor node.

Tests

  • graph/test/csharp/staging-test.sh adds the issue's repro in both shapes, each with its own staged library. On the base it fails both checks (the declared constructor gives 2 rows, 1 of them external; no constructor gives an external row). Here it passes.
  • C# suite (graph/test/csharp/run-tests.sh: cases scored against the Roslyn oracle, staging-test.sh, tools/*-test.sh including library-resolution-test.sh): oracle self-test 7/7, cases 22/22 (100% cover / agree / fan each), staging PASS, all 10 tools gates ok, exit 0.
  • graph/test/tools/bundle-test.sh passes (schema doc current). gen_decls_all.py --check is clean.
  • No golden files moved. The per-case suite stages every lib_* relation empty, and every new clause needs a lib type, so it cannot fire there.

…or (#1339)

With a C# library staged, `new Store()` on a library type was still reported
as a construction of an unstaged dependency.

Declared constructor: the site had two rows, the resolved one and
`external:Store.<constructor>` (provenance external). The cause is
call_ctor_target_accepts in external-types.dl, which re-checked that the
target accepts the argument count under the SITE's provenance. A client site
that reaches a library constructor has the constructor under "lib", so the
check found nothing and the "staged type, no carried constructor" clause
labelled a resolved site as unstaged. call_ctor_target already checks the
arity under the constructor's own provenance, so the relation now reads it
as is.

No constructor carried: the site was `external:Store.<constructor>`, which
says the dependency was not supplied. It now has one row to
`generated:<qualified type name>#<constructor>/0` with callee_provenance lib
and tier boundary_lib; the bundle gives that id a methods row with
provenance generated, as it does for a delegate member's Invoke. `new T()`
compiles only if T has a parameterless constructor, so the target exists,
but a library IR is a signature subset and cannot say whether T declares it,
so the site is still kept out of known_implicit_ctor. A site whose argument
count no carried constructor accepts, where the IR carries some, keeps its
external label, like an uncarried method.

Tests: staging-test.sh gains both shapes; it fails on the base (2 rows /
external) and passes here.
… keeps its own version)

0.2.3 is released, so what merges into this branch ships in 0.2.4. package.json (version and the five @axiomcode/engine-* pins) and the four editor plugin and extension manifests move from 0.2.3 to 0.2.4. The parser keeps its own version.
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit e7bcb65 into 0.2.4 Nov 19, 2026
13 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the fix/csharp-staged-ctor-not-external branch November 19, 2026 04:31
@swapnilpaliwal-sd swapnilpaliwal-sd mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant